<template>
  <AMISRenderer :schema="schema" />
</template>

<script setup>
import AMISRenderer from '@/components/AMISRenderer.vue'
import detail from "./detail"

const schema = {
  type: 'page',
  name: 'orgEntpPage',
  body:[
    {
      type: 'crud',
      name: 'entpTable',
      syncLocation: false,
      api: '/upms/mgr/org/entp/list',
      autoFillHeight: true,
      columnsTogglable: false,
      footerToolbar: [
        'statistics',
        'switch-per-page',
        'pagination'
      ],
      autoGenerateFilter: {
        showBtnToolbar: false,
        columnsNum: 4
      },
      columns:[
        {
          label: '企业名称',
          name: 'orgName',
          searchable: {
              type: 'input-text',
              name: 'orgName',
              label: '企业名称',
              clearable: true
          }
        },
        {
          label: '统一社会信用代码',
          name: 'registerCode',
          searchable: {
              type: 'input-text',
              name: 'registerCode',
              label: '统一社会信用代码',
              clearable: true,
              labelWidth: 130,
          }
        },
        {
          label: '企业类型',
          name: 'entpTypeStr',
          searchable: {
              type: 'select',
              name: 'entpType',
              label: '企业类型',
              source: '/base/dict/options/entp-type',
              clearable: true,
              labelWidth: 130,
          }
        },
        {
          label: '被授权人',
          name: 'authName'
        },
        {
          label: '被授权人手机号',
          name: 'authPhone'
        },
        {
          name: 'mainUserName',
          label: '主账号'
        },
        {
          name: 'provinceName',
          label: '省',
          hiddenOn: '1',
          searchable: {
            type: 'select',
            name: 'provinceCode',
            label: '省',
            source: '/base/district/province',
            valueField: 'regionCode',
            labelField: 'regionName',
            clearable: true,
          }
        },
        {
          name: 'cityName',
          label: '市',
          hiddenOn: '1',
          searchable: {
            type: 'select',
            name: 'cityCode',
            label: '市',
            source: {
              url: '/base/district/children?parentId=${provinceCode}',
              sendOn: '${provinceCode}',
            },
            valueField: 'regionCode',
            labelField: 'regionName',
            clearable: true,
          }
        },
        {
          name: 'areaName',
          label: '县',
          hiddenOn: '1',
          searchable: {
            type: 'select',
            name: 'areaCode',
            label: '县',
            source: {
              url: '/base/district/children?parentId=${cityCode}',
              sendOn: '${cityCode}',
            },
            valueField: 'regionCode',
            labelField: 'regionName',
            clearable: true,
          }
        },
        {
          label: '申请时间',
          name: 'gmtCreated'
        },
        {
          type: 'operation',
          label: '操作',
          buttons: [
            {
              label: '查看',
              type: 'button',
              actionType: 'dialog',
              visibleOn: '${checkStatus != 1}',
              dialog:{
                  title: '企业信息',
                  closeOnEsc: true,
                  showErrorMsg: false,
                  body: detail,
                  size: 'full',
                  actions:[
                  {
                    type: 'button',
                    label: '返回',
                    level: 'primary',
                    actionType: 'close'
                  }
                ]
              }
            },
          ]
        }
      ]
    }
  ]
}

</script>
